package com.dachuang.canjiren.service.impl;

import com.dachuang.canjiren.entity.LawComment;
import com.dachuang.canjiren.entity.Message;
import com.dachuang.canjiren.entity.VO.CommentVO;
import com.dachuang.canjiren.mapper.LawCommentMapper;
import com.dachuang.canjiren.mapper.MessageMapper;
import com.dachuang.canjiren.service.MessageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dachuang.common.exception.BizCodeEnume;
import com.dachuang.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author testjava
 * @since 2020-07-27
 */
@Service
public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> implements MessageService {
    @Autowired
    private MessageMapper messageMapper;
    @Override
    public R insertMessage(Integer sendID, Integer secId, String content) {
        Message message = new Message();
        message.setId(secId);
        message.setSecId(secId);
        message.setContent(content);
        if (messageMapper.insertMessage(message) > 0){
            return R.ok();
        }
        return R.error();
    }

    @Override
    public R selectMessage(Integer id) {
        if (Objects.isNull(id)){
            return R.error(BizCodeEnume.VAILD_EXCEPTION);
        }
        Message message = messageMapper.selectMessage(id);
        R r = R.ok();
        r.put("data",message);
        return r;
    }
}
